package com.tiancheng.trade.order.service;

import com.tiancheng.trade.commom.core.data.PageInfo;
import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.commom.core.exception.BusinessException;
import com.tiancheng.trade.order.vo.api.CreditOrderVo;
import com.tiancheng.trade.order.vo.api.RefundAuditVO;
import com.tiancheng.trade.order.vo.api.RefundVO;
import com.tiancheng.trade.order.vo.api.res.RefundCreateResVO;
import com.tiancheng.trade.order.vo.parallel.*;
import com.tiancheng.trade.order.vo.parallel.res.*;

import java.util.Map;

/**
 * 新老系统并行数据处理Service接口
 *
 * @author kellen
 * @date 2024/6/5
 */
public interface OrderParallelService {

    /**
     * 查询用户的订单列表
     * @param orderQueryVO
     * @return
     */
    PageInfo<OrderQueryResVO> findByUser(OrderQueryVO orderQueryVO);
    /**
     * 查询用户的订单列表
     * @param orderQueryVO
     * @return
     */
    PageInfo<OrderQueryResNewVO> findByUserNew(OrderQueryVO orderQueryVO);

    /**
     * 查询用户的退款列表
     * @param refundQueryVO
     * @return
     */
    PageInfo<RefundQueryResVO> findRefundByUser(RefundQueryVO refundQueryVO);

    /**
     * 查询用户的退款列表
     * @param refundQueryVO
     * @return
     */
    PageInfo<RefundQueryResNewVO> findRefundByUserNew(RefundQueryVO refundQueryVO);

    /**
     * 初始化收银台
     * @param cashierParallelVO
     * @return
     */
    CashierParallelResVO initCashier(CashierParallelVO cashierParallelVO);

    /**
     * 支付
     * @param orderPayParallelVO
     * @return
     */
    OrderPrePayParallelResVO pay(OrderPayParallelVO orderPayParallelVO);

    /**
     * 查询订单支付状态
     * @param uid
     * @param orderId
     * @return
     */
    Map<String, String> getPayStatus(String uid, String orderId);

    /**
     * 创建退款
     * @param refundVO
     * @return
     * @throws BusinessException
     */
    RefundCreateResVO createRefund(RefundVO refundVO) throws BusinessException;

    /**
     * 提交退款
     * @param refundAuditVO
     * @return
     */
    Result submitRefund(RefundAuditVO refundAuditVO);

    /**
     * 子订单状态流转，要触发核销
     * @param orderId
     * @param subOrderId
     * @param bizStatus
     */
    void subOrderStatusFlow(String orderId, String[] subOrderId, String bizStatus);

    /**
     * 查询免押订单oderStr
     * @param orderId
     * @return
     */
    String getOrderStr(String orderId);
    /**
     * 查询已创建的预授权订单信息
     * @param alipayAuthNo
     * @return
     */
    CreditOrderVo queryCreditOrder(String alipayAuthNo);

    /**
     * 完结预授权订单
     * @param alipayAuthNo 预授权订单id
     * @param payAmount 需要预授权转支付的金额
     * @param bizComplete 是否履约 0 否 1 是
     * @param description 完结说明
     * @return
     */
    Result finishCreditOrder(String alipayAuthNo,Integer payAmount,Integer bizComplete,String description);

    /**
     * 取消预授权订单
     * @param alipayAuthNo
     * @param remark
     * @return
     */
    Result cancelCreditOrder(String alipayAuthNo, String remark);

    /**
     * 主动查询预授权回调状态
     * @param orderId 订单中心订单id
     * @return
     */
    CreditOrderVo queryConfirmStatus(String orderId);

    /**
     * 同步老订单系统状态
     * @param params
     * @return
     */
    Result updateCreditOrderState(Map<String,Object> params);

    AppleInAppPayResVO appleInAppPay(AppleInAppPayVO appleInAppPayVO);

    String deductionPay(OrderDeductionPayParallelVO orderPayVO);
}
